﻿using System;

using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;

using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Dominio;
using Servicios;

namespace EstadisticaProduce.Acuicultura
{
    public partial class Default : System.Web.UI.Page
    {
        clsAcuicultura _consultas = new clsAcuicultura();
        string err_mens = string.Empty;
        ArrayList l = new ArrayList();
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack) {
                //GetTeclado();
            }
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string CLA_USUARIO = txtPassword.Text;
            string COD_USUARIO = txtUsuario.Text;

            if (CLA_USUARIO == string.Empty) {
                CLA_USUARIO = "0";            
            }

            Hashtable ht = new Hashtable();
            ht.Add("COD_USUARIO", COD_USUARIO);
            ht.Add("CLA_USUARIO", Convert.ToDecimal(CLA_USUARIO));

            List<domConsultasGenerales> lst = new List<domConsultasGenerales>();
            lst = _consultas.LogeoUsuario(ht);

            if (lst.Count == 0)
            {
                pnlMensaje.Visible = true;
                l_mensaje.Text = "Usuario o Clave incorrectos";
            }
            else {
                if (lst[0].estusuario == "A")
                {
                    pnlMensaje.Visible = true;
                    Response.Redirect("frmControlPanel.aspx");       
                }
                else {
                    pnlMensaje.Visible = true;
                    l_mensaje.Text = "Usuario no activo";
                }
            }
        }

        public void GetTeclado()
        {
            l.Add("1");
            l.Add("2");
            l.Add("3");
            l.Add("4");
            l.Add("5");
            l.Add("6");
            l.Add("7");
            l.Add("8");
            l.Add("9");
            l.Add("0");

            RandomOrder(l);
            string s_tempo = "";

            s_tempo = Convert.ToChar(13) + "<table style='background-color:#DCDCDC;' id=" + Convert.ToChar(34) + "ctl00_cphP_tecladoPass_tblTeclado" + Convert.ToChar(34) + " width=" + Convert.ToChar(34) + "100px" + Convert.ToChar(34) + " height=" + Convert.ToChar(34) + "77px" + Convert.ToChar(34) + " border=" + Convert.ToChar(34) + "1" + Convert.ToChar(34) + ">" + Convert.ToChar(13);
            s_tempo += "<tr>" + Convert.ToChar(13);
            s_tempo += "<td id=" + Convert.ToChar(34) + "ctl00_cphP_tecladoPass_num1" + Convert.ToChar(34) + " class='cl_teclado_item' style='width:33%;' onmouseover=" + Convert.ToChar(34) + "bgr_color(this, '#faffcc');" + Convert.ToChar(34) + " onmouseout=" + Convert.ToChar(34) + "bgr_color(this, '#DCDCDC')" + Convert.ToChar(34) + " onclick=" + Convert.ToChar(34) + "MuestraNumero('" + l[0] + "');" + Convert.ToChar(34) + ">" + l[0] + "</td>" + Convert.ToChar(13);
            s_tempo += "<td id=" + Convert.ToChar(34) + "ctl00_cphP_tecladoPass_num2" + Convert.ToChar(34) + " class='cl_teclado_item' style='width:33%;' onmouseover=" + Convert.ToChar(34) + "bgr_color(this, '#faffcc');" + Convert.ToChar(34) + " onmouseout=" + Convert.ToChar(34) + "bgr_color(this, '#DCDCDC')" + Convert.ToChar(34) + " onclick=" + Convert.ToChar(34) + "MuestraNumero('" + l[1] + "');" + Convert.ToChar(34) + ">" + l[1] + "</td>" + Convert.ToChar(13);
            s_tempo += "<td id=" + Convert.ToChar(34) + "ctl00_cphP_tecladoPass_num3" + Convert.ToChar(34) + " class='cl_teclado_item' style='width:33%;' onmouseover=" + Convert.ToChar(34) + "bgr_color(this, '#faffcc');" + Convert.ToChar(34) + " onmouseout=" + Convert.ToChar(34) + "bgr_color(this, '#DCDCDC')" + Convert.ToChar(34) + " onclick=" + Convert.ToChar(34) + "MuestraNumero('" + l[2] + "');" + Convert.ToChar(34) + ">" + l[2] + "</td></tr>" + Convert.ToChar(13);
            s_tempo += "<tr>" + Convert.ToChar(13);
            s_tempo += "<td id=" + Convert.ToChar(34) + "ctl00_cphP_tecladoPass_num4" + Convert.ToChar(34) + "  class='cl_teclado_item' onmouseover=" + Convert.ToChar(34) + "bgr_color(this, '#faffcc');" + Convert.ToChar(34) + " onmouseout=" + Convert.ToChar(34) + "bgr_color(this, '#DCDCDC')" + Convert.ToChar(34) + " onclick=" + Convert.ToChar(34) + "MuestraNumero('" + l[3] + "');" + Convert.ToChar(34) + ">" + l[3] + "</td>" + Convert.ToChar(13);
            s_tempo += "<td id=" + Convert.ToChar(34) + "ctl00_cphP_tecladoPass_num5" + Convert.ToChar(34) + "  class='cl_teclado_item' onmouseover=" + Convert.ToChar(34) + "bgr_color(this, '#faffcc');" + Convert.ToChar(34) + " onmouseout=" + Convert.ToChar(34) + "bgr_color(this, '#DCDCDC')" + Convert.ToChar(34) + " onclick=" + Convert.ToChar(34) + "MuestraNumero('" + l[4] + "');" + Convert.ToChar(34) + ">" + l[4] + "</td>" + Convert.ToChar(13);
            s_tempo += "<td id=" + Convert.ToChar(34) + "ctl00_cphP_tecladoPass_num6" + Convert.ToChar(34) + "  class='cl_teclado_item' onmouseover=" + Convert.ToChar(34) + "bgr_color(this, '#faffcc');" + Convert.ToChar(34) + " onmouseout=" + Convert.ToChar(34) + "bgr_color(this, '#DCDCDC')" + Convert.ToChar(34) + " onclick=" + Convert.ToChar(34) + "MuestraNumero('" + l[5] + "');" + Convert.ToChar(34) + ">" + l[5] + "</td></tr>" + Convert.ToChar(13);
            s_tempo += "<tr>" + Convert.ToChar(13);
            s_tempo += "<td id=" + Convert.ToChar(34) + "ctl00_cphP_tecladoPass_num7" + Convert.ToChar(34) + "  class='cl_teclado_item' onmouseover=" + Convert.ToChar(34) + "bgr_color(this, '#faffcc');" + Convert.ToChar(34) + " onmouseout=" + Convert.ToChar(34) + "bgr_color(this, '#DCDCDC')" + Convert.ToChar(34) + " onclick=" + Convert.ToChar(34) + "MuestraNumero('" + l[6] + "');" + Convert.ToChar(34) + ">" + l[6] + "</td>" + Convert.ToChar(13);
            s_tempo += "<td id=" + Convert.ToChar(34) + "ctl00_cphP_tecladoPass_num8" + Convert.ToChar(34) + "  class='cl_teclado_item' onmouseover=" + Convert.ToChar(34) + "bgr_color(this, '#faffcc');" + Convert.ToChar(34) + " onmouseout=" + Convert.ToChar(34) + "bgr_color(this, '#DCDCDC')" + Convert.ToChar(34) + " onclick=" + Convert.ToChar(34) + "MuestraNumero('" + l[7] + "');" + Convert.ToChar(34) + ">" + l[7] + "</td>" + Convert.ToChar(13);
            s_tempo += "<td id=" + Convert.ToChar(34) + "ctl00_cphP_tecladoPass_num9" + Convert.ToChar(34) + "  class='cl_teclado_item' onmouseover=" + Convert.ToChar(34) + "bgr_color(this, '#faffcc');" + Convert.ToChar(34) + " onmouseout=" + Convert.ToChar(34) + "bgr_color(this, '#DCDCDC')" + Convert.ToChar(34) + " onclick=" + Convert.ToChar(34) + "MuestraNumero('" + l[8] + "');" + Convert.ToChar(34) + ">" + l[8] + "</td></tr>" + Convert.ToChar(13);
            s_tempo += "<tr>" + Convert.ToChar(13);
            s_tempo += "<td id=" + Convert.ToChar(34) + "ctl00_cphP_tecladoPass_num0" + Convert.ToChar(34) + "  class='cl_teclado_item' onmouseover=" + Convert.ToChar(34) + "bgr_color(this, '#faffcc');" + Convert.ToChar(34) + " onmouseout=" + Convert.ToChar(34) + "bgr_color(this, '#DCDCDC')" + Convert.ToChar(34) + " onClick=" + Convert.ToChar(34) + "MuestraNumero('" + l[9] + "');" + Convert.ToChar(34) + ">" + l[9] + "</td>" + Convert.ToChar(13);
            s_tempo += "<td id=" + Convert.ToChar(34) + "ctl00_cphP_tecladoPass_cellLimpiar" + Convert.ToChar(34) + " colspan=" + Convert.ToChar(34) + "2" + Convert.ToChar(34) + "  class='cl_teclado_item' onmouseover=" + Convert.ToChar(34) + "bgr_color(this, '#faffcc');this.style.cursor= 'pointer'" + Convert.ToChar(34) + " onmouseout=" + Convert.ToChar(34) + "bgr_color(this, '#DCDCDC');this.style.cursor='default'" + Convert.ToChar(34) + " OnClick=" + Convert.ToChar(34) + "Limpia();" + Convert.ToChar(34) + ">-&raquo; limpiar</td></tr>" + Convert.ToChar(13);
            s_tempo += "</table>" + Convert.ToChar(13);
            l_teclado.Text = s_tempo;
        }

        public void RandomOrder(ArrayList arrList)
        {
            Random r = new Random();
            for (int cnt = 0; cnt < arrList.Count; cnt++)
            {
                object tmp = arrList[cnt];
                int idx = r.Next(arrList.Count - cnt) + cnt;
                arrList[cnt] = arrList[idx];
                arrList[idx] = tmp;
            }

        }

    }
}